#include <stdio.h>
#include <stdlib.h>
#include "fileUtil.h"

void readFile(char *file,void (handleLine)(char *line)) {
#ifdef DEBUG
    printf("fileUtil.read %s\n",file);
#endif

    FILE *srcFile = fopen(file, "r");
    if(srcFile==NULL){
        printf("open file(%s) failed\n",file);
        return;
    }
    char *buffer = calloc(1024, sizeof(char));
    char *pb;
    while ((pb = fgets(buffer, 1024, srcFile)) != NULL) {
        if(buffer[0]=='\n'){
            continue;
        }
        handleLine(buffer);
    }
    free(buffer);
    fclose(srcFile);
}
